package tests;

import Common.Utils;
import org.openqa.selenium.By;

public class firstPage extends Utils {
    public static String url = "http://localhost:8080/";

    public firstPage() {
        super(url);
    }


    //检查页面是否加载成功
    public void firstPageRight() throws InterruptedException {
        //通过查看页面元素是否存在来检查页面加载成功与否
        driver.findElement(By.cssSelector("#globalHeader > div:nth-child(2) > div > a"));
        driver.findElement(By.cssSelector("#globalHeader > div:nth-child(1) > div > div > div > div.arco-menu-item.arco-menu-disabled > div"));
        Thread.sleep(1000);
    }

    //答题页-答题
    public void firstAns() throws InterruptedException {
        driver.navigate().refresh();
        driver.findElement(By.cssSelector("#homePage > div.arco-list-wrapper.list-demo-action-layout > div > div.arco-scrollbar.arco-scrollbar-type-embed > div > div > div > div > div:nth-child(1) > div > div.arco-card-cover > div > img")).click();
        driver.findElement(By.cssSelector("#appDetailPage > div > div > div > div.arco-col.content-wrapper > div > div:nth-child(1) > a")).click();
        //1
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(4) > span > label.arco-radio.arco-radio-checked > span.arco-radio-label")).click();
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(5) > div > div > button")).click();
        //2
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(4) > span > label:nth-child(1) > span.arco-radio-label")).click();
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(5) > div > div:nth-child(1) > button")).click();
        //3
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(4) > span > label:nth-child(1) > span.arco-radio-label")).click();
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(5) > div > div:nth-child(1) > button")).click();
        //4
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(4) > span > label:nth-child(1) > span.arco-radio-label")).click();
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(5) > div > div:nth-child(1) > button")).click();
        //5
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(4) > span > label:nth-child(1) > span.arco-radio-label")).click();
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(5) > div > div:nth-child(1) > button")).click();
        //6
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(4) > span > label:nth-child(1) > span.arco-radio-label")).click();
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(5) > div > div:nth-child(1) > button")).click();
        //7
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(4) > span > label:nth-child(1) > span.arco-radio-label")).click();
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(5) > div > div:nth-child(1) > button")).click();
        //8
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(4) > span > label:nth-child(1) > span.arco-radio-label")).click();
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(5) > div > div:nth-child(1) > button")).click();
        //9
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(4) > span > label:nth-child(1) > span.arco-radio-label")).click();
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(5) > div > div:nth-child(1) > button")).click();
        //10
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(4) > span > label:nth-child(1) > span.arco-radio-label")).click();
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(5) > div > div:nth-child(1) > button")).click();
        Thread.sleep(3000);
        //回到主页
        driver.findElement(By.cssSelector("   #globalHeader > div:nth-child(1) > div > div > div > div.arco-menu-item.arco-menu-selected")).click();
    }


    //答题页-答题不答题目直接下一题
    public void firstAnsFail() throws InterruptedException {
        driver.navigate().refresh();
        driver.findElement(By.cssSelector("#homePage > div.arco-list-wrapper.list-demo-action-layout > div > div.arco-scrollbar.arco-scrollbar-type-embed > div > div > div > div > div:nth-child(1) > div > div.arco-card-cover > div > img")).click();
        driver.findElement(By.cssSelector("#appDetailPage > div > div > div > div.arco-col.content-wrapper > div > div:nth-child(1) > a")).click();
        //1
        driver.findElement(By.cssSelector("#doAnswerPage > div > div > div:nth-child(5) > div > div > button")).click();
        String currentUrl = driver.getCurrentUrl();
        assert "http://localhost:8080/answer/do/1".equals(currentUrl);
        //回到主页
        driver.findElement(By.cssSelector("   #globalHeader > div:nth-child(1) > div > div > div > div.arco-menu-item.arco-menu-selected")).click();

    }
    // //答题页-答题不答题目直接下一题
    // public void firstCreateAl() throws InterruptedException {
    //     driver.navigate().refresh();
    //     driver.findElement(By.cssSelector("#homePage > div.arco-list-wrapper.list-demo-action-layout > div > div.arco-scrollbar.arco-scrollbar-type-embed > div > div > div > div > div:nth-child(1) > div > div.arco-card-cover > div > img")).click();
    //     driver.findElement(By.cssSelector("#appDetailPage > div > div > div > div.arco-col.content-wrapper > div > div:nth-child(3) > a")).click();
    //     //选择Al生成题目
    //     driver.findElement(By.cssSelector("#addQuestionPage > form > div:nth-child(2) > div.arco-col.arco-form-item-wrapper-col > div > div > div.arco-space.arco-space-horizontal.arco-space-align-center > div:nth-child(2) > button")).click();
    //     driver.findElement(By.cssSelector("body > div.arco-drawer-container > div.arco-drawer > div.arco-drawer-body > div > form > div:nth-child(4) > div.arco-col.arco-form-item-wrapper-col > div > div > div > div:nth-child(1) > button")).click();
    //     //回到主页
    //     driver.findElement(By.cssSelector("   #globalHeader > div:nth-child(1) > div > div > div > div.arco-menu-item.arco-menu-selected")).click();

    // }
}
